package mediadisplay.ui 
{
	import flash.display.GradientType;
	import flash.display.SpreadMethod;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.filters.DropShadowFilter;
	import flash.filters.GlowFilter;
	import flash.geom.Matrix;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFieldType;
	import flash.text.TextFormat;
	/**
	 * ...
	 * @author Anders Figenschow selvfølgelig
	 */
	public class FunButton extends Sprite
	{
		private var _txt:String;
		private var textformat:TextFormat;
		private var tf:TextField;
		
		public function FunButton(txt:String) 
		{
			_txt = txt;
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			var fType:String = GradientType.LINEAR;
			var colors:Array = [ 0xffffff, 0 ];
			var alphas:Array = [ 0.7, 0.9 ];
			var ratios:Array = [ 0, 255 ];
			var matr:Matrix = new Matrix();
			matr.createGradientBox( 100, 150, 0, 0, 0 );
			matr.rotate(Math.PI/-1.9);
			var sprMethod:String = SpreadMethod.PAD;
			
			graphics.clear();
			graphics.beginGradientFill( fType, colors, alphas, ratios, matr, sprMethod );
			graphics.drawRoundRect(0, 0, 150, 50, 10, 10);
			graphics.endFill();			
			
			textformat = new TextFormat();
			textformat.color = 0;
			textformat.size = 20;
			
			tf = new TextField();
			addChild(tf);
			tf.defaultTextFormat = textformat;
			tf.autoSize = TextFieldAutoSize.LEFT;
			tf.text = _txt;
			tf.selectable = false;
			tf.mouseEnabled = false;
			tf.type = TextFieldType.DYNAMIC;
			tf.y = 10;
			tf.x = width / 2 - tf.width / 2;
			tf.cacheAsBitmap = true;
			tf.filters = [new GlowFilter(0x000000, 0.4, 6, 6, 1)];
			
			buttonMode = true;
			filters = [new GlowFilter(0xffffff, 0.6, 8, 8, 2), new DropShadowFilter(4, 45, 0, 0.6)];
			
		}
	}

}